package com.sea.finance.service.impl;

import com.sea.finance.entity.ExchangeRateRecord;
import com.sea.finance.entity.InventoryStock;
import com.sea.finance.mapper.ExchangeRateRecordMapper;
import com.sea.finance.mapper.InventoryStockMapper;
import com.sea.finance.service.ExchangeRateRecordService;
import com.sea.finance.service.InventoryStockService;
import com.sea.product.entity.Product;
import com.sea.product.service.ProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author 陈鸿飞
 */
@Service
public class InventoryStockServiceImpl implements InventoryStockService {

    @Autowired
    private InventoryStockMapper inventoryStockMapper;
    @Autowired
    private InventoryStockService inventoryStockService;
    @Autowired
    private ProductService productService;

    @Override
    public List<InventoryStock> findByCnd(InventoryStock inventoryStock) {
        return inventoryStockMapper.findByCnd(inventoryStock);
    }

    @Override
    public Integer save(InventoryStock inventoryStock) {

        return inventoryStockMapper.insert(inventoryStock);
    }

    @Override
    public void updateByMonth() {
        List<Product> list = productService.getProduce(null);

        for(Product product:list){
            InventoryStock inventoryStock=new InventoryStock();
            BeanUtils.copyProperties(product,inventoryStock);
            inventoryStockService.save(inventoryStock);
        }
    }
}
